<div class="wrapper-bz-page">
    <div class="wrapper-bz-body">
        <div class="column-block block-left" style="left:0px; width:300px;">
            <div class="column-title">省份</div>
            <div class="column-content">
                <div class="column-filter">
                    <div class="common-search-box">
                        <input style="width:120px"  id="search_input_geo_province_in_m80" />
                    </div>
                </div>
                <div class="column-datagrid">
                    <table id="table_geo_province_in_m80" style="width:100%;height:100%"></table>
                </div>
            </div>
        </div>
        <div class="column-block block-left" style="left:310px; width:300px;">
            <div class="column-title">城市</div>
            <div class="column-content">
                <div class="column-filter">
                    <div class="common-search-box">
                        <input style="width:120px"  id="search_input_geo_city_in_m80" />
                    </div>
                </div>
                <div class="column-datagrid">
                    <table id="table_geo_city_in_m80" style="width:100%;height:100%"></table>
                </div>
            </div>
        </div>
        <div class="column-block block-left" style="left:620px; width:300px;">
            <div class="column-title">县区</div>
            <div class="column-content">
                <div class="column-filter">
                    <div class="common-search-box">
                        <input style="width:120px"  id="search_input_geo_area_in_m80" />
                    </div>
                </div>
                <div class="column-datagrid">
                    <table id="table_geo_area_in_m80" style="width:100%;height:100%"></table>
                </div>
            </div>
        </div>
        <div class="column-block block-right" style="left:930px; ">
            <div class="column-block block-up">
                <div class="column-title">美食</div>
                <div class="column-content">
                    <div class="common-add-box">
                        <input style="width:120px"  id="add_input_geo_food_in_m80" /><i class="fa fa-plus-circle" style="color:green" id="btn_add_input_geo_food_in_m80"></i>
                    </div>
                    <div class="box-tag-list" id="box_tag_list_geo_food_in_m80">

                    </div>
                </div>
            </div>
            <div class="column-block block-down">
                <div class="column-title">风景</div>
                <div class="column-content">
                    <div class="common-add-box">
                        <input style="width:120px"  id="add_input_geo_scenery_in_m80" /><i class="fa fa-plus-circle" style="color:green" id="btn_add_input_geo_scenery_in_m80"></i>
                    </div>
                    <div id="box_tag_list_geo_scenery_in_m80">

                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<div id="dialog_add_geo_province_in_m80"></div>
<div id="dialog_edit_geo_province_in_m80"></div>
<div id="dialog_add_geo_city_in_m80"></div>
<div id="dialog_edit_geo_city_in_m80"></div>
<div id="dialog_add_geo_area_in_m80"></div>
<div id="dialog_edit_geo_area_in_m80"></div>

<div id="dialog_bind_datagrid_column_in_m80"></div>
<script>
    $(function () {
        var subject_1 = "geo_province_in_m80";
        var subject_2 = "geo_city_in_m80";
        var subject_3 = "geo_area_in_m80";
        //列表-对话框-表单
        var tableId_1 = 'table_' + subject_1;
        var tableId_2 = 'table_' + subject_2;
        var tableId_3 = 'table_' + subject_3;

        var searchInputId_1 = 'search_input_' + subject_1;
        var searchInputId_2 = 'search_input_' + subject_2;
        var searchInputId_3 = 'search_input_' + subject_3;

        var tableObject_1 = $('#' + tableId_1);
        var tableObject_2 = $('#' + tableId_2);
        var tableObject_3 = $('#' + tableId_3);

        var addDialogId_1 = '#dialog_add_' + subject_1;
        var addDialogId_2 = '#dialog_add_' + subject_2;
        var addDialogId_3 = '#dialog_add_' + subject_3;

        var editDialogId_1 = '#dialog_edit_' + subject_1;
        var editDialogId_2 = '#dialog_edit_' + subject_2;
        var editDialogId_3 = '#dialog_edit_' + subject_3;


        var addFormId_1 = '#form_add_' + subject_1;
        var addFormId_2 = '#form_add_' + subject_2;
        var addFormId_3 = '#form_add_' + subject_3;
        var editFormId_1 = '#form_edit_' + subject_1;
        var editFormId_2 = '#form_edit_' + subject_2;
        var editFormId_3 = '#form_edit_' + subject_3;

        var paramDataAdd_1 = {};
        var paramDataAdd_2 = {};
        var paramDataAdd_3 = {};
        var paramDataEdit_1 = {};
        var paramDataEdit_2 = {};
        var paramDataEdit_3 = {};

        var selectLeftMainId_1 = 0;
        var selectLeftMainId_2 = 0;
        var configDialogAdd_1 = {
            href: '/admin/GeoProvince/pageAdd',
            title: '新增省份',
            queryParams: {},
            width: dialogDefaultWidth,
            height: dialogDefaultHeight,
            modal: true,
            buttons: [{
                text: '<i class="fa fa-check fa-btn-cls" style="color:green"></i>保存',
                plain: true,
                handler: function () {
                    paramDataAdd_1 = $(addFormId_1).serializeObject();
                    if (!paramDataAdd_1.province_code) {
                        layer.msg("请填写省份代号");
                        return;
                    }

                    if (!paramDataAdd_1.province_name) {
                        layer.msg("请填写省份名称");
                        return;
                    }

                    var loading = layer.load(1, {
                        shade: [0.1, '#fff'] //0.1透明度的白色背景
                    });
                    $.ajax({
                        url: '/api/GeoProvince/addGeoProvince',
                        async: false,
                        dataType: 'json',
                        type: 'post',
                        data: paramDataAdd_1,
                        success: function (resp) {
                            layer.close(loading);
                            if (1 == resp.code) {
                                $(addDialogId_1).dialog('close');
                                tableObject_1.datagrid('reload');
                            } else {
                                layer.msg(resp.message);
                            }
                        }
                    });
                }
            }, {
                text: '<i class="fa fa-times fa-btn-cls" style="color:red"></i>取消',
                plain: true,
                handler: function () {
                    $(addDialogId_1).dialog('close');
                }
            }]
        };

        var configDialogAdd_2 = {
            href: '/admin/GeoCity/pageAdd',
            title: '新增城市',
            queryParams: {},
            width: dialogDefaultWidth,
            height: dialogDefaultHeight,
            modal: true,
            buttons: [{
                text: '<i class="fa fa-check fa-btn-cls" style="color:green"></i>保存',
                plain: true,
                handler: function () {
                    paramDataAdd_2 = $(addFormId_2).serializeObject();
                    paramDataAdd_2 = $.extend(paramDataAdd_2, {geo_province_id: selectLeftMainId_1});

                    if (!paramDataAdd_2.city_code) {
                        layer.msg("请填写城市代号");
                        return;
                    }

                    if (!paramDataAdd_2.city_name) {
                        layer.msg("请填写城市名称");
                        return;
                    }
                    var loading = layer.load(1, {
                        shade: [0.1, '#fff'] //0.1透明度的白色背景
                    });
                    $.ajax({
                        url: '/api/GeoCity/addGeoCity',
                        async: false,
                        dataType: 'json',
                        type: 'post',
                        data: paramDataAdd_2,
                        success: function (resp) {
                            layer.close(loading);
                            if (1 == resp.code) {
                                $(addDialogId_2).dialog('close');
                                tableObject_2.datagrid('reload');
                            } else {
                                layer.msg(resp.message);
                            }
                        }
                    });
                }
            }, {
                text: '<i class="fa fa-times fa-btn-cls" style="color:red"></i>取消',
                plain: true,
                handler: function () {
                    $(addDialogId_2).dialog('close');
                }
            }]
        };
        var configDialogAdd_3 = {
            href: '/admin/GeoArea/pageAdd',
            title: '新增区县',
            queryParams: {},
            width: dialogDefaultWidth,
            height: dialogDefaultHeight,
            modal: true,
            buttons: [{
                text: '<i class="fa fa-check fa-btn-cls" style="color:green"></i>保存',
                plain: true,
                handler: function () {
                    paramDataAdd_3 = $(addFormId_3).serializeObject();
                    paramDataAdd_3 = $.extend(paramDataAdd_3, {geo_city_id: selectLeftMainId_2});
                    console.log(paramDataAdd_3);
                    if (!paramDataAdd_3.area_code) {
                        layer.msg("请填写区县代号");
                        return;
                    }

                    if (!paramDataAdd_3.area_name) {
                        layer.msg("请填写区县名称");
                        return;
                    }
                    var loading = layer.load(1, {
                        shade: [0.1, '#fff'] //0.1透明度的白色背景
                    });
                    $.ajax({
                        url: '/api/GeoArea/addGeoArea',
                        async: false,
                        dataType: 'json',
                        type: 'post',
                        data: paramDataAdd_3,
                        success: function (resp) {
                            layer.close(loading);
                            if (1 == resp.code) {
                                $(addDialogId_3).dialog('close');
                                tableObject_3.datagrid('reload');
                            } else {
                                layer.msg(resp.message);
                            }
                        }
                    });
                }
            }, {
                text: '<i class="fa fa-times fa-btn-cls" style="color:red"></i>取消',
                plain: true,
                handler: function () {
                    $(addDialogId_3).dialog('close');
                }
            }]
        };
        var configDialogEdit_1 = {
            href: '/admin/GeoProvince/pageEdit',
            title: '修改省份',
            queryParams: {},
            width: dialogDefaultWidth,
            height: dialogDefaultHeight,
            modal: true,
            buttons: [{
                text: '<i class="fa fa-check fa-btn-cls" style="color:green"></i>保存',
                plain: true,
                handler: function () {
                    paramDataEdit_1 = $(editFormId_1).serializeObject();
                    if (!paramDataEdit_1.province_code) {
                        layer.msg("请填写省份代号");
                        return;
                    }

                    if (!paramDataEdit_1.province_name) {
                        layer.msg("请填写省份名称");
                        return;
                    }
                    var loading = layer.load(1, {
                        shade: [0.1, '#fff'] //0.1透明度的白色背景
                    });
                    $.ajax({
                        url: '/api/GeoProvince/editGeoProvince',
                        type: 'post',
                        data: paramDataEdit_1,
                        dataType: 'json',
                        async: false,
                        success: function (resp) {
                            layer.close(loading);
                            if (0 == resp.code) {
                                layer.msg(resp.message);
                            } else {
                                $(editDialogId_1).dialog('close');
                                tableObject_1.datagrid('reload');
                            }
                        }
                    });
                }
            }, {
                text: '<i class="fa fa-times fa-btn-cls" style="color:red"></i>取消',
                plain: true,
                handler: function () {
                    $(editDialogId_1).dialog('close');
                }
            }]
        };

        var configDialogEdit_2 = {
            href: '/admin/GeoCity/pageEdit',
            title: '修改城市',
            queryParams: {},
            width: dialogDefaultWidth,
            height: dialogDefaultHeight,
            modal: true,
            buttons: [{
                text: '<i class="fa fa-check fa-btn-cls" style="color:green"></i>保存',
                plain: true,
                handler: function () {
                    paramDataEdit_2 = $(editFormId_2).serializeObject();
                    if (!paramDataEdit_2.city_code) {
                        layer.msg("请填写城市代号");
                        return;
                    }

                    if (!paramDataEdit_2.city_name) {
                        layer.msg("请填写城市名称");
                        return;
                    }
                    var loading = layer.load(1, {
                        shade: [0.1, '#fff'] //0.1透明度的白色背景
                    });
                    $.ajax({
                        url: '/api/GeoCity/editGeoCity',
                        type: 'post',
                        data: paramDataEdit_2,
                        dataType: 'json',
                        async: false,
                        success: function (resp) {
                            layer.close(loading);
                            if (0 == resp.code) {
                                layer.msg(resp.message);
                            } else {
                                $(editDialogId_2).dialog('close');
                                tableObject_2.datagrid('reload');
                            }
                        }
                    });
                }
            }, {
                text: '<i class="fa fa-times fa-btn-cls" style="color:red"></i>取消',
                plain: true,
                handler: function () {
                    $(editDialogId_2).dialog('close');
                }
            }]
        };

        var configDialogEdit_3 = {
            href: '/admin/GeoArea/pageEdit',
            title: '修改区县',
            queryParams: {},
            width: dialogDefaultWidth,
            height: dialogDefaultHeight,
            modal: true,
            buttons: [{
                text: '<i class="fa fa-check fa-btn-cls" style="color:green"></i>保存',
                plain: true,
                handler: function () {
                    paramDataEdit_3 = $(editFormId_3).serializeObject();
                    if (!paramDataEdit_3.area_code) {
                        layer.msg("请填写区县代号");
                        return;
                    }

                    if (!paramDataEdit_3.area_name) {
                        layer.msg("请填写区县名称");
                        return;
                    }
                    var loading = layer.load(1, {
                        shade: [0.1, '#fff'] //0.1透明度的白色背景
                    });
                    $.ajax({
                        url: '/api/GeoArea/editGeoArea',
                        type: 'post',
                        data: paramDataEdit_3,
                        dataType: 'json',
                        async: false,
                        success: function (resp) {
                            layer.close(loading);
                            if (0 == resp.code) {
                                layer.msg(resp.message);
                            } else {
                                $(editDialogId_3).dialog('close');
                                tableObject_3.datagrid('reload');
                            }
                        }
                    });
                }
            }, {
                text: '<i class="fa fa-times fa-btn-cls" style="color:red"></i>取消',
                plain: true,
                handler: function () {
                    $(editDialogId_3).dialog('close');
                }
            }]
        };

        var configDatagrid_1 = {
            url: '/api/GeoProvince/getGeoProvinceOption',
            method: 'post',
            remoteSort: false,
            queryParams: {},
            pageList: [25, 50, 100],
            pageSize: 50,
            pagination: false,
            clickToEdit: false,
            dblclickToEdit: false,
            singleSelect: true,
            checkOnSelect: false,
            selectOnCheck: false,
            rownumbers: false,
            striped: true,
            fitColumns: true,
            fit: true,
            frozenColumns: [[
                {field: 'ck', title: 'ck', checkbox: true},
            ]],
            columns: [[
                {field: 'id', title: 'ID', width: 40, hidden: true},
                {field: 'province_name', title: '省份名称', width: 100},
            ]],
            loadFilter: function (data) {
                return loadFilter(data, false);
            },
            onSelect: function (index, row) {
                configDatagrid_2.queryParams = {province_code: row.province_code};
                configDatagrid_3.queryParams = {province_code: row.province_code};
                tableObject_2.datagrid(configDatagrid_2);
                tableObject_3.datagrid(configDatagrid_3);

                SearchCombobox(searchInputId_2, tableId_2,function (val,name) {
                    configDatagrid_2.queryParams = {};
                    configDatagrid_2.queryParams[name] = val;
                    tableObject_2.datagrid(configDatagrid_2);
                },['ck', 'ID', '序号']);

                SearchCombobox(searchInputId_3, tableId_3,function (val,name) {
                    configDatagrid_3.queryParams = {};
                    configDatagrid_3.queryParams[name] = val;
                    tableObject_3.datagrid(configDatagrid_3);
                },['ck', 'ID', '序号']);

                selectLeftMainId_1 = row.id;
            },
            onClickRow: function (index, row) {
                // console.log("enter click row");
                // selectLeftMainId = row.id;
                // configDatagrid_2.queryParams = {datagrid_id:row.id};
                // tableObject_2.datagrid(configDatagrid_2);
            },
            onCheck: function (index, row) {
            },
            onUncheck: function (index, row) {
            },
            onLoadSuccess: function () {
                tableObject_1.datagrid('selectRow', 0);
                // $(".datagrid-header-check").html("");
            },
            toolbar: [
                {
                    text: '<span class="tool-btn-refresh"><i class="fa fa-refresh"></i>刷新</span>',
                    plain: true,
                    handler: function () {
                        tableObject_1.datagrid('reload');
                    }
                },
                {
                    text: '<span class="tool-btn-add"><i class="fa fa-plus"></i>新增</span>',
                    plain: true,
                    handler: function () {
                        $(addDialogId_1).dialog(configDialogAdd_1);
                    }
                },
                {
                    text: '<span class="tool-btn-edit"><i class="fa fa-pencil"></i>编辑</span>',
                    plain: true,
                    handler: function () {
                        var rows = tableObject_1.datagrid("getChecked");
                        if (0 == rows.length) {
                            layer.msg("请勾选要编辑的省份");
                            return false;
                        }
                        configDialogEdit_1.queryParams = {id: rows[0].id};
                        $(editDialogId_1).dialog(configDialogEdit_1);
                    }
                },
                {
                    text: '<span class="tool-btn-delete"><i class="fa fa-trash"></i>删除</span>',
                    plain: true,
                    handler: function () {
                        var rows = tableObject_1.datagrid("getChecked");
                        if (0 == rows.length) {
                            layer.msg("请勾选要删除的省份");
                            return false;
                        }

                        var arrId = [];
                        $.each(rows, function (index, item) {
                            arrId.push(item.id);
                        });
                        var confirm = layer.confirm('你确定要删除?', {title: '执行操作', btn: ['是', '否']}, function () {
                            $.ajax({
                                url: '/api/GeoProvince/deleteMultiGeoProvince',
                                type: 'post',
                                data: {arr_id: arrId},
                                dataType: 'json',
                                async: false,
                                success: function (resp) {
                                    layer.close(confirm);
                                    if (0 == resp.code) {
                                        layer.msg(resp.message);
                                    }
                                    tableObject_1.datagrid('reload');
                                }
                            });
                        });
                    }
                }
            ]

        };
        var configDatagrid_2 = {
            url: '/api/GeoCity/getGeoCityOption',
            method: 'post',
            remoteSort: false,
            queryParams: {},
            pageList: [30, 50, 100],
            pageSize: 30,
            pagination: false,
            clickToEdit: false,
            dblclickToEdit: true,
            singleSelect: true,
            checkOnSelect: true,
            selectOnCheck: true,
            rownumbers: false,
            striped: true,
            fitColumns: true,
            fit: true,
            frozenColumns: [[
                {field: 'ck', title: 'ck', checkbox: true},
                {field: 'id', title: 'ID', width: 40, hidden: true},
            ]],
            columns: [[
                {field: 'city_name', title: '城市名称', width: 100, editor: 'textbox'},
            ]],
            loadFilter: function (data) {
                return loadFilter(data, false);
            },
            onSelect: function (index, row) {
                selectLeftMainId_2 = row.id;
                configDatagrid_3.queryParams = {city_code: row.city_code};
                tableObject_3.datagrid(configDatagrid_3);

                refreshTagListGeoFood(row.id, 0);
            },
            onCheck: function (row) {
            },
            onUncheck: function (row) {
            },
            onEndEdit: function (index, row, changes) { //在完成编辑但编辑器还没有销毁之前触发
                console.log("end edit:", index, row);
                if (JSON.stringify(changes) != '{}') {
                    var updateData = $.extend({id: row.id}, changes);
                    $.ajax({
                        url: '/api/DatagridColumn/simpleUpdateDatagridColumn',
                        type: 'post',
                        data: updateData,
                        dataType: 'json',
                        async: false,
                        success: function (resp) {
                            if (0 == resp.code) {
                                layer.msg(resp.message);
                            } else {
                                //tableObject_2.datagrid('updateRow', index);
                                tableObject_2.datagrid('reload');
                            }
                        }
                    });
                }
            },
            onLoadSuccess: function () {
            },
            toolbar: [
                {
                    text: '<span class="tool-btn-refresh"><i class="fa fa-refresh"></i>刷新</span>',
                    plain: true,
                    handler: function () {
                        tableObject_2.datagrid('reload');
                    }
                },
                {
                    text: '<span class="tool-btn-add"><i class="fa fa-plus"></i>新增</span>',
                    plain: true,
                    handler: function () {
                        var rows = tableObject_1.datagrid("getChecked");
                        if (0 == rows.length) {
                            layer.msg("请勾选要新增城市的省份");
                            return false;
                        }
                        $(addDialogId_2).dialog(configDialogAdd_2);
                    }
                },
                {
                    text: '<span class="tool-btn-edit"><i class="fa fa-pencil"></i>编辑</span>',
                    plain: true,
                    handler: function () {
                        var rows = tableObject_2.datagrid("getChecked");
                        if (0 == rows.length) {
                            layer.msg("请勾选要编辑的城市");
                            return false;
                        }
                        configDialogEdit_2.queryParams = {id: rows[0].id};
                        $(editDialogId_2).dialog(configDialogEdit_2);
                    }
                },
                {
                    text: '<span class="tool-btn-delete"><i class="fa fa-trash"></i>删除</span>',
                    plain: true,
                    handler: function () {
                        var rows = tableObject_2.datagrid("getChecked");
                        if (0 == rows.length) {
                            layer.msg("请勾选要删除的城市");
                            return false;
                        }

                        var arrId = [];
                        $.each(rows, function (index, item) {
                            arrId.push(item.id);
                        });
                        var confirm = layer.confirm('你确定要删除?', {title: '执行操作', btn: ['是', '否']}, function () {
                            $.ajax({
                                url: '/api/GeoCity/deleteMultiGeoCity',
                                type: 'post',
                                data: {arr_id: arrId},
                                dataType: 'json',
                                async: false,
                                success: function (resp) {
                                    layer.close(confirm);
                                    if (0 == resp.code) {
                                        layer.msg(resp.message);
                                    }
                                    tableObject_2.datagrid('reload');
                                }
                            });
                        });
                    }
                }
            ]

        };
        var configDatagrid_3 = {
            url: '/api/GeoArea/getGeoAreaOption',
            method: 'post',
            remoteSort: false,
            queryParams: {},
            pageList: [30, 50, 100],
            pageSize: 100,
            pagination: false,
            clickToEdit: false,
            dblclickToEdit: true,
            singleSelect: false,
            checkOnSelect: false,
            selectOnCheck: true,
            rownumbers: false,
            striped: true,
            fitColumns:true,
            fit:true,
            frozenColumns: [[
                {field: 'ck', title: 'ck', checkbox: true},
                {field: 'id', title: 'ID', width: 40, hidden: true},
            ]],
            columns: [[
                {field: 'area_name', title: '县区名称', width: 60, editor: 'textbox'},
            ]],
            loadFilter: function (data) {
                return loadFilter(data, false);
            },
            onClickRow: function (index, row) {
                // console.log("enter click row");
                // selectLeftMainId = row.id;
                // configDatagrid_2.queryParams = {datagrid_id:row.id};
                // tableObject_2.datagrid(configDatagrid_2);
            },
            onCheck: function (index, row) {
                refreshTagListGeoFood(0, row.id);
            },
            onUncheck: function (index, row) {
                refreshTagListGeoFood(selectLeftMainId_2, 0);
            },
            onEndEdit: function (index, row, changes) { //在完成编辑但编辑器还没有销毁之前触发
                if (JSON.stringify(changes) != '{}') {
                    var updateData = $.extend({id: row.id}, changes);
                    $.ajax({
                        url: '/api/DatagridToolbar/simpleUpdateDatagridToolbar',
                        type: 'post',
                        data: updateData,
                        dataType: 'json',
                        async: false,
                        success: function (resp) {
                            if (0 == resp.code) {
                                layer.msg(resp.message);
                            } else {
                                tableObject_3.datagrid('reload');
                            }
                        }
                    });
                }
            },
            onLoadSuccess: function () {
                $("#btn_edit_in_page_toolbar").linkbutton('disable');
                $("#btn_delete_in_page_toolbar").linkbutton('disable');
                $(".switchbtn-pagetoolbar").switchbutton({
                    height: 18,
                    onText: "是",
                    offText: "否",
                    onChange: function (value) {
                        var newValue = value ? 1 : 2;
                        var pageToolbarId = $(this).data("id");
                        var fieldName = $(this).data("field");
                        togglePageToolbar(pageToolbarId, fieldName, newValue);
                    }
                })
            },
            toolbar: [
                {
                    text: '<span class="tool-btn-refresh"><i class="fa fa-refresh"></i>刷新</span>',
                    plain: true,
                    handler: function () {
                        tableObject_3.datagrid('reload');
                    }
                },
                {
                    text: '<span class="tool-btn-add"><i class="fa fa-plus"></i>新增</span>',
                    plain: true,
                    handler: function () {
                        var rows = tableObject_2.datagrid("getChecked");
                        if (0 == rows.length) {
                            layer.msg("请勾选要新增区县的城市");
                            return false;
                        }
                        $(addDialogId_3).dialog(configDialogAdd_3);
                    }
                },
                {
                    text: '<span class="tool-btn-edit"><i class="fa fa-pencil"></i>编辑</span>',
                    plain: true,
                    handler: function () {
                        var rows = tableObject_3.datagrid("getChecked");
                        if (0 == rows.length) {
                            layer.msg("请勾选要编辑的区县");
                            return false;
                        }
                        configDialogEdit_3.queryParams = {id: rows[0].id};
                        $(editDialogId_3).dialog(configDialogEdit_3);
                    }
                },
                {
                    text: '<span class="tool-btn-delete"><i class="fa fa-trash"></i>删除</span>',
                    plain: true,
                    handler: function () {
                        var rows = tableObject_3.datagrid("getChecked");
                        if (0 == rows.length) {
                            layer.msg("请勾选要删除的区县");
                            return false;
                        }
                        var arrId = [];
                        $.each(rows, function (index, item) {
                            arrId.push(item.id);
                        });
                        var confirm = layer.confirm('你确定要删除?', {title: '执行操作', btn: ['是', '否']}, function () {
                            $.ajax({
                                url: '/api/GeoArea/deleteMultiGeoArea',
                                type: 'post',
                                data: {"arr_id": arrId},
                                dataType: 'json',
                                success: function (resp) {
                                    layer.close(confirm);
                                    if (1 == resp.code) {
                                        tableObject_3.datagrid('reload');
                                    } else {
                                        layer.msg(resp.message);
                                    }
                                }
                            });
                        });
                    }
                }
            ]

        };
        tableObject_1.datagrid(configDatagrid_1);

        SearchCombobox(searchInputId_1, tableId_1,function (val,name) {
            configDatagrid_1.queryParams = {};
            configDatagrid_1.queryParams[name] = val;
            tableObject_1.datagrid(configDatagrid_1);
        },['ck','ID']);

        // SearchCombobox(searchInputId_3, tableId_3,function (val,name) {
        //     configDatagrid_3.queryParams = {};
        //     configDatagrid_3.queryParams[name] = val;
        //     tableObject_3.datagrid(configDatagrid_3);
        // },['ck','ID']);

        // SearchCombobox('search_input_user_in_role','table_user_in_role',function (val,name) {
        //     configDatagrid_1.queryParams = {};
        //     configDatagrid_1.queryParams[name] = val;
        //     if(selectRoleId){
        //         configDatagrid_1.queryParams['role_id'] = selectRoleId;
        //     }
        //     tableObject_1.datagrid(configDatagrid_1);
        // },['ck','ID']);

        $("#btn_add_input_geo_food_in_m80").click(function(){
            var checkAreaList = tableObject_3.datagrid("getChecked");
            var checkCityList = tableObject_2.datagrid("getChecked");
            var checkAreaId = 0;
            var checkCityId = 0;
            if(0 == checkAreaList.length){
                if(0 == checkCityList.length){
                    layer.msg("请勾选城市");
                    return false;
                }
                checkCityId = checkCityList[0].id;
            }else{
                checkAreaId = checkAreaList[0].id;
            }

            var foodName = $("#add_input_geo_food_in_m80").val();
            if(0 == foodName.replace(/\s/g, '').length){
                layer.msg("请填写美食名称");
                return false;
            }
            $.ajax({
                url: '/api/GeoFood/addGeoFood',
                type: 'post',
                data: {"area_id": checkAreaId, "city_id": checkCityId, "food_name":foodName},
                dataType: 'json',
                success: function (resp) {
                    if (1 == resp.code) {
                        refreshTagListGeoFood(checkCityId, checkAreaId);
                    } else {
                        layer.msg(resp.message);
                    }
                }
            });
        });

        function refreshTagListGeoFood(cityId, areaId)
        {
            $.ajax({
                url: '/api/GeoFood/getGeoFoodOption',
                type: 'post',
                data: {"city_id": cityId, "area_id":areaId},
                dataType: 'json',
                success: function (resp) {
                    if (1 == resp.code) {
                        renderTagBox("box_tag_list_geo_food_in_m80", resp.data, "food_name");
                    } else {
                        layer.msg(resp.message);
                    }
                }
            });
        }

        function refreshTagListGeoScenery(areaCode)
        {
            $.ajax({
                url: '/api/GeoScenery/getGeoSceneryOption',
                type: 'post',
                data: {"area_code": areaCode},
                dataType: 'json',
                success: function (resp) {
                    if (1 == resp.code) {
                        renderTagBox("box_tag_list_geo_scenery_in_m80", resp.data, "scenery_name");
                    } else {
                        layer.msg(resp.message);
                    }
                }
            });
        }

    });


</script>
